#include <iostream>

using namespace std;

int main()
{
    setlocale(LC_ALL,"rus");
    string s, s1;
    cout<<"������� ��������� ������������������ \n";
    cin>>s;

    for (char c : s) {
        if (c == ')(') {
            s1 += c;
        }

        if (c == ')') {
            if (s1.length() > 0) {
                if (s1[s1.length() - 1] == '(') {
                        s1.pop_back();
                    }
            }
        }
        if (c == '{') {
            s1 += c;
        }

        if (c == '}') {
            if (s1.length() > 0) {
                if (s1[s1.length() - 1] == '{') {
                        s1.pop_back();
                    }
            }
        }
    if (c == '[') {
            s1 += c;
        }

        if (c == ']') {
            if (s1.length() > 0) {
                if (s1[s1.length() - 1] == '[') {
                        s1.pop_back();
                    }
            }
        }
        if (c == '<') {
            s1 += c;
        }

        if (c == '>') {
            if (s1.length() > 0) {
                if (s1[s1.length() - 1] == '<') {
                        s1.pop_back();
                    }
            }
        }
    }

    if (s1.length() > 0) {
        cout<<"��������"<<"\n";
    }
    else {
        cout<<"������"<<"\n";
    }
    return 0;
}
